package com.yuwei.mine.view

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import com.alibaba.android.arouter.facade.annotation.Route
import com.blankj.utilcode.util.LogUtils
import com.yuwei.base.RoutePath
import com.yuwei.common.mvi.BaseMviFragment
import com.yuwei.common.mvi.UiState
import com.yuwei.database.entity.OrderEntity
import com.yuwei.mine.MineIntent
import com.yuwei.mine.MineViewModel
import com.yuwei.mine.R
import com.yuwei.mine.adapter.OrderMultiAdapter
import com.yuwei.mine.databinding.FragmentOrderBinding

/**
 * 全部
 */
@Route(path = RoutePath.MODULE_MINE_ORDER_FRAGMENT)
class AllOrderFragment : BaseMviFragment<FragmentOrderBinding,MineViewModel>() {
    private val orderMultiAdapter = OrderMultiAdapter()
    override fun successData(it: UiState.onSuccess<*>) {
        when(it.type){
            "getOrder"->{
                orderMultiAdapter.data.addAll(it.data as List<OrderEntity>)
                orderMultiAdapter.notifyDataSetChanged()
            }
        }
    }

    override fun failureData(error: String) {

    }

    override fun initView() {
        vm.sendIntent(MineIntent.getOrder)
    }

    override fun initData() {
        binding.allOrderRv.adapter = orderMultiAdapter
        binding.allOrderRv.layoutManager = LinearLayoutManager(requireContext())

    }


}